onPostPublish
Callback to receive the data published from the editor. This callback is available in both createPost
and editPost
methods and is triggered when the user clicks the "Publish" button inside the editor interface.
Usage
With createPost:
predis.createPost({
onPostPublish: function (error, data) {
if (error) {
console.error("Error publishing new post:", error);
} else {
console.log("New post published successfully:", data);
}
},
});
With editPost:
predis.editPost({
post_id: "YOUR_POST_ID",
onPostPublish: function (error, data) {
if (error) {
console.error("Error publishing edited post:", error);
} else {
console.log("Edited post published successfully:", data);
}
},
});
Parameters
Name | Description | Type | Required |
---|---|---|---|
error | Error triggered when the post failed to publish otherwise null | Error | yes |
data | The data of the published post inthe format given below. | Object | yes |
data.media_url | An array containing URL(s) of the published media. This can be a URL for a jpeg or mp4 file.In case when data.media_type is single_image or video the array will contain only one item, while in case of carousel it can contain multiple items. | Array | yes |
data.post_id | An unique ID to identify the published post. | String | yes |
data.thumb_url | An URL for the thumbnail of the published media. | String | yes |
data.media_type | Media type of the published media. Can be one of single_image , carousel or video | String | yes |
data.caption | Caption of the generated content. | String | yes |